package com.cj.user.service.lintcode;

import org.junit.platform.commons.util.StringUtils;

/**
 * @Author cheng jun
 * @Description:本题我们要编写代码去除字符串 str 中的空格，然后返回去除空格后的字符串长度。
 * @Date 2021/6/13 21:50
 */
public class Demo1 {

    public static int removeSpaces(String str) {
        String[] strArray = str.split("");
        StringBuffer stringBuffer = new StringBuffer();
        for (String s : strArray) {
            if (!StringUtils.isBlank(s)) {
                stringBuffer.append(s);
            }
        }
        int strLength = stringBuffer.length();
        return strLength;
    }

    public static void main(String[] args) {
        String str = " a bc  de  f";
        System.out.println(Demo1.removeSpaces(str));
    }
}
